#ifndef TREEMESH_H
#define TREEMESH_H

#include <vector>
#include "common.h"
#include "treegen.h"
#include "constants.h"
#include <qgl.h>
#include <QGLShaderProgram>

using std::vector;


struct Tri{

    Tri(int a, int b, int c){
        v0 = a;
        v1 = b;
        v2 = c;
    }

    bool end;
    union{
        struct{
           int v0, v1, v2;
        };
        int verts[3];
    };
};

struct Leaf{
    double3 tl, tr, bl, br, normal;
};

class TreeMesh
{
public:
    TreeMesh(TreeGen* gen, Renderer *rend);
    ~TreeMesh();
    void draw(bool leafs);
    void makeTextures();

    void chooseLeafColor(char choice);

    float3          *m_color, *m_range;
    vector<double3> *m_verts, *m_norms, *m_tangents;
    vector<Tri>     *m_tris;
    vector<int> num_tris;
        vector<float2> *m_texCoords;
        vector<Bud *> *m_buds;
    vector<Leaf>**   m_leafs;
    QGLShaderProgram* m_shader;
    Renderer * render;
    GLuint            m_tex;
};

#endif // TREEMESH_H
